// component/singlechoice/singlechoice.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: ''
    },
    radioArr: {
      type: Array,
      value: []
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    value: [],
    modelHidden: true,
    animationData: {}
  },

  /**
   * 组件的方法列表
   */
  methods: {
    showModel: function () {
      const that = this;
      this.setData({
        modelHidden: false
      }, () => {
        let animation = wx.createAnimation({
          duration: 600,
          timingFunction: '"ease"',
        })
        this.animation = animation;
        setTimeout(function () {
          that.fadeIn();
        }, 200)
      })
    },
    hideModel: function () {
      const that = this;
      let animation = wx.createAnimation({
        duration: 800,
        timingFunction: '"ease"'
      })
      this.animation = animation;
      that.fadeDown();
      setTimeout(function () {
        that.setData({
          modelHidden: true
        })
      }, 200) //先执行下滑动画，再隐藏模块
    },
    // 动画效果
    fadeIn: function () {
      this.animation.translateY(0).step();
      this.setData({
        animationData: this.animation.export()
      })
    },
    fadeDown: function () {
      this.animation.translateY(300).step();
      this.setData({
        animationData: this.animation.export()
      })
    },
    clickCancel: function () {
      this.hideModel();
    }
  }
})
